package edu.esiag.isidis.fi.lb;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

public class WorkThread<EntityType,InformationType> implements Runnable{
	private static final String RUN_METHODE = "runProcess";
	
	protected EntityType entity;
	protected InformationType information;
	
	public WorkThread(EntityType entity,InformationType information) {
		this.entity=entity;
		this.information=information;
	}
	public void run() {
		try {
			Method method = entity.getClass().getDeclaredMethod(RUN_METHODE, new Class[]{ information.getClass() });
			method.invoke(entity, information);
		} catch (SecurityException e) {
			e.printStackTrace();
		} catch (NoSuchMethodException e) {
			e.printStackTrace();
		} catch (IllegalArgumentException e) {
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			e.printStackTrace();
		} catch (InvocationTargetException e) {
			e.printStackTrace();
		}
	}
}
